package com.zhj.bz.datastructure.queue;

import java.util.Queue;
import java.util.Scanner;

/**
 * @author zhj
 */
public class ArrayQueueDemo {
    public static void main(String[] args) {
        ArrayQueue arrayQueue = new ArrayQueue(3);
        char key = ' ';
        // 用户输入
        Scanner scanner = new Scanner(System.in);
        boolean loop = true;
        while (loop) {
            System.out.println("s(show): 显示队列");
            System.out.println("e(exit): 退出程序");
            System.out.println("h(head): 队头");
            System.out.println("a(add) : 入队");
            System.out.println("g(get) : 出队");
            key = scanner.next().charAt(0);
            switch (key) {
                case 's' :
                    arrayQueue.show();
                    break;
                case 'e' :
                    System.out.println("程序退出！");
                    loop = false;
                    break;
                case 'h' :
                    try {
                        System.out.println(arrayQueue.headQueue());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case 'a' :
                    System.out.println("请输入一个数：");
                    int value = scanner.nextInt();
                    arrayQueue.addData(value);
                    break;
                case 'g' :
                    try {
                        System.out.println(arrayQueue.getData());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
            }
        }
        arrayQueue.show();
    }
}
